import {energyStationEquipMaintenanceApi} from '@/api/equip/energyStationEquipMaintenance.js'

export const FormEvent = {
  OptionData_yxzt: [],
  OptionData_sblxmc: [],
  OptionData_djhszt: [],
  form: {
    sbbm: "",
    gldwbm: "",
    gldwmc: "",
    wzlbbm: "",
    wzlbmc: "",
    sblxbm: "",
    sblxmc: "",
    sbmc: "",
    ccbm: "",
    ssjfbm: "",
    ssjfmc: "",
    ccrq: "",
    cjmc: "",
    yxzt: "",
    yxztmc: "",
    tyrq: "",
    xh: "",
    eddy: "",
    bz: "",
    eddl: "",
    pl: "",
    fhdj: "",
    q: "",
    h: "",
    n: "",
    wt: "",
    bzzll: "",
    zlgl: "",
    bzzrl: "",
    zlj: "",
    dy: "",
    jzzl: "",
    czl: "",
    wxcc: "",
    sfqy: "",
    cjr: "",
    cjtime: "",
    sbzp: "",
    zb: ""
  },
  rules: {
    gldwbm: [
      {required: true, message: '管理单位 不能为空', trigger: 'blur'},
    ],
    sblxbm: [
      {required: true, message: '设备类型 不能为空', trigger: 'blur'},
    ],
    sbmc: [
      {required: true, message: '设备名称 不能为空', trigger: 'blur'},
    ],
    ccbm: [
      {required: true, message: '出厂编码 不能为空', trigger: 'blur'},
    ],
    ssjfbm: [
      {required: true, message: '所属库房 不能为空', trigger: 'blur'},
    ],
    ccrq: [
      {required: true, message: '出厂日期 不能为空', trigger: 'blur'},
    ],
    tyrq: [
      {required: true, message: '投运日期 不能为空', trigger: 'blur'},
    ],
    yxzt: [
      {required: true, message: '运行状态 不能为空', trigger: 'blur'},
    ],
    xh: [
      {required: true, message: '型号 不能为空', trigger: 'blur'},
    ],
    eddy: [
      {required: true, message: '额定电压 不能为空', trigger: 'blur'},
    ],
    bz: [
      {required: true, message: '标准 不能为空', trigger: 'blur'}
    ],
    eddl: [
      {required: true, message: '额定电流 不能为空', trigger: 'blur'}
    ],
    pl: [
      {required: true, message: '频率 不能为空', trigger: 'blur'}
    ],
    fhdj: [
      {required: true, message: '防护等级 不能为空', trigger: 'blur'}
    ],
    q: [
      {required: true, message: 'Q 不能为空', trigger: 'blur'}
    ],
    h: [
      {required: true, message: 'H 不能为空', trigger: 'blur'}
    ],
    n: [
      {required: true, message: 'N 不能为空', trigger: 'blur'}
    ],
    wt: [
      {required: true, message: 'Wt 不能为空', trigger: 'blur'}
    ],
    bzzll: [
      {required: true, message: '标准制冷量 不能为空', trigger: 'blur'}
    ],
    zlgl: [
      {required: true, message: '制冷功率 不能为空', trigger: 'blur'}
    ],
    bzzrl: [
      {required: true, message: '标准制热量 不能为空', trigger: 'blur'}
    ],
    zlj: [
      {required: true, message: '制冷剂 不能为空', trigger: 'blur'}
    ],
    dy: [
      {required: true, message: '电源 不能为空', trigger: 'blur'}
    ],
    jzzl: [
      {required: true, message: '机组重量 不能为空', trigger: 'blur'}
    ],
    czl: [
      {required: true, message: '充注量 不能为空', trigger: 'blur'}
    ],
    wxcc: [
      {required: true, message: '外形尺寸 不能为空', trigger: 'blur'}
    ],
  },
  type: '', ////insert-update//
  initFormData(formData) { 		//初始化表单信�?//
    FormEvent.type = formData.type;
    if (FormEvent.type == 'insert') {
      for (let key in FormEvent.form) {
        FormEvent.form[key] = undefined;
      }
      FormEvent.form.wzlbbm = '2000'
      FormEvent.form.wzlbmc = '能源站物资'

    } else {
      for (let key in FormEvent.form) {
        FormEvent.form[key] = formData.data[key];
      }
    }
  },
  saveFormData() {
    if (FormEvent.type == 'insert') {
      //执行新增操作//
      const insertData = [FormEvent.form];
      return energyStationEquipMaintenanceApi.insert(insertData);
    } else if (FormEvent.type == 'update') {
      //执行更新操作//
      const updateData = [FormEvent.form];
      return energyStationEquipMaintenanceApi.update(updateData);
    }
  },
}


